<?php
/**
 * DBShop 电子商务系统
 *
 * ==========================================================================
 * @link      http://www.dbshop.net/
 * @copyright Copyright (c) 2012-2015 DBShop.net Inc. (http://www.dbshop.net)
 * @license   http://www.dbshop.net/license.html License
 * ==========================================================================
 *
 * @author    静静的风
 *
 */

namespace Paper\Model;

use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;
use Zend\Db\Sql\Expression;
use Paper\Model\Paper as dbshopCheckInData;

class PaperTable extends AbstractTableGateway implements \Zend\Db\Adapter\AdapterAwareInterface
{
    protected $table = 'dbshop_paper';

    public function setDbAdapter(Adapter $adapter)
    {
        $this->adapter     = $adapter;
        $this->initialize();
    }
    /**
     * Paper信息列表
     * @param array $pageArray
     * @param array $where
     * @param array $order
     * @return Paginator
     */
    public function listDeliveryAddress (array $pageArray, array $where, array $order=array())
    {
      $select = new Select(array('dbshop_paper'=>$this->table));
	  $select->where($where);
      $select->order($order);
	  $pageAdapter = new DbSelect($select, $this->adapter);
	  $paginator   = new Paginator($pageAdapter);
	  $paginator->setCurrentPageNumber($pageArray['page']);
      $paginator->setItemCountPerPage($pageArray['page_num']);
	  //print_r("ac");die();
	return $paginator;
    }
      /**
     * 添加Paper
     * @param array $data
     * @return int|null
     */
    public function addPaper (array $data)
	
    {
        $row = $this->insert(dbshopCheckInData::addPaperData($data));
        if($row) {
            return $this->getLastInsertValue();
        }
        return null;
    }
	    /**
     * Paper信息
     * @param array $where
     * @return array|\ArrayObject|null
     */
    public function infoOrder (array $where)
    {
		//print_r("a".$where);die();
        $result = $this->select($where);
        if($result) {
            return $result->current();
        }
        return null;
    }
  
}